#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n = 0;
    int sum = 0;
    while (scanf("%d", &n) != EOF)
    {
        int a1 = 3 * 1 - 1;
        int an = 3 * n - 1;
        sum = n * (a1 + an) / 2;
        printf("%d", sum);
    }
    return 0;
}
int main1()
{
    int n = 0;
    int sum = 0;
    while (scanf("%d", &n) != EOF)
    {
        int i = 0;
        for (i = 1; i <= n; i++)
        {
            sum += (3 * i - 1);
        }
        printf("%d\n", sum);
    }
    return 0;
}